home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 25
/
Volume 25 - JOGO DISK .iso
/
Games
/
the_jewel_hunter.swf
/
scripts
/
Blocker.as
< prev
next >
Wrap
Text File
|
2006-06-13
|
6KB
|
230 lines
classBlock = function()
{
this.init();
};
classBlock.prototype = new MovieClip();
Object.registerClass("Blocker",classBlock);
classBlock.prototype.init = function()
{
var _loc1_ = this;
Game.block = _loc1_;
_loc1_.createEmptyMovieClip("holder",10);
_loc1_.available = new Array(8);
_loc1_.block_type = new Array("Cactus","Rock");
_loc1_.lastCreate = 0;
_loc1_.onEnterFrame = _loc1_.movement;
};
classBlock.prototype.movement = function()
{
var _loc1_ = this;
if(Game.start)
{
if(_loc1_.count >= 60)
{
if(_loc1_.depth > 65530)
{
_loc1_.depth = 0;
}
_loc1_.itemcount = _loc1_.itemcount + 1;
if(_loc1_.itemcount >= 8)
{
_loc1_.createBonus();
}
var _loc2_ = random(_loc1_.available.length - _loc1_.lastCreate);
_loc1_.create(_loc2_);
_loc1_.count = 0;
}
else
{
_loc1_.count += Game.speed;
}
_loc1_.update();
}
};
classBlock.prototype.create = function(count)
{
var _loc1_ = this;
var toCreate = Math.min(Math.min(5,Game.level),count);
var created = toCreate;
_loc1_.lastCreate = 0;
do
{
var _loc3_ = random(_loc1_.available.length - 1);
if(!_loc1_.available[_loc3_])
{
created--;
_loc1_.available[_loc3_] = true;
_loc1_.lastCreate = _loc1_.lastCreate + 1;
_loc1_.depth = _loc1_.depth + 1;
var type = random(_loc1_.block_type.length);
var _loc2_ = _loc1_.holder.attachMovie(_loc1_.block_type[type],_loc1_.block_type[type] + _loc1_.depth,_loc1_.depth);
_loc2_.gotoAndStop(random(_loc2_._totalframes) + 1);
_loc2_._x = _loc3_ * 47.5 + 23.75 + random(10) - 5;
_loc2_._y = -30 + random(10) - 5;
_loc2_._xscale = _loc2_._yscale = random(30) + 80;
_loc2_.pos = _loc3_;
_loc2_.type = 1;
}
toCreate--;
}
while(toCreate > 0);
if(created > 0)
{
if(_loc1_.snakeCount < Game.level && _loc1_.snakeCount < 3)
{
_loc1_.createSnake();
}
}
};
classBlock.prototype.createSnake = function()
{
var _loc2_ = this;
if(random(100) < 80)
{
_loc2_.createBike();
}
else
{
var _loc3_ = random(350);
var dir = random(2);
_loc2_.snakeCount += 1;
_loc2_.depth = _loc2_.depth + 1;
var _loc1_ = _loc2_.holder.attachMovie("snake","snake" + _loc2_.depth,_loc2_.depth);
_loc1_.type = 2;
if(dir == 0)
{
_loc1_.dir = - (random(Math.min(5,Game.level)) + 1);
_loc1_._x = 400;
_loc1_._xscale = -100;
}
else
{
_loc1_.dir = random(Math.min(5,Game.level)) + 1;
_loc1_._x = -20;
}
_loc1_._y = _loc3_;
}
};
classBlock.prototype.createBike = function()
{
var _loc1_ = this;
if(_loc1_.bikeCount < Math.min(5,Game.level))
{
var _loc3_ = random(_loc1_.available.length - 1);
if(!_loc1_.available[_loc3_])
{
_loc1_.bikeCount = _loc1_.bikeCount + 1;
_loc1_.depth = _loc1_.depth + 1;
var _loc2_ = _loc1_.holder.attachMovie("Bike","Bike" + _loc1_.depth,_loc1_.depth);
_loc2_._x = _loc3_ * 47.5 + 23.75;
_loc2_._y = -30;
_loc2_.start = false;
_loc2_.xspeed = _loc2_.yspeed = Math.min(5,random(Game.level) + 1);
_loc2_.type = 3;
}
}
};
classBlock.prototype.createBonus = function(count)
{
var _loc1_ = this;
if(_loc1_.itemdir)
{
var _loc3_ = random(4);
}
else
{
_loc3_ = random(4) + 4;
}
_loc1_.itemdir = !_loc1_.itemdir;
if(!_loc1_.available[_loc3_])
{
_loc1_.available[_loc3_] = true;
_loc1_.lastCreate = _loc1_.lastCreate + 1;
_loc1_.depth = _loc1_.depth + 1;
_loc1_.itemcount = 0;
var type;
var bonus;
if(random(100) > 90)
{
type = "bonus";
bonus = 100;
}
else
{
type = "items";
bonus = 25;
}
var _loc2_ = _loc1_.holder.attachMovie(type,type + _loc1_.depth,_loc1_.depth);
_loc2_.gotoAndStop(random(_loc2_._totalframes) + 1);
_loc2_._x = _loc3_ * 47.5 + 23.75;
_loc2_._y = -30;
_loc2_.pos = _loc3_;
_loc2_.type = 0;
_loc2_.bonus = bonus;
}
};
classBlock.prototype.update = function()
{
var _loc2_ = this;
for(var _loc3_ in _loc2_.holder)
{
var _loc1_ = _loc2_.holder[_loc3_];
_loc1_._y += Game.speed;
if(_loc1_.type == 0)
{
if(_loc1_.pos != undefined)
{
if(_loc1_._y > 200)
{
_loc2_.available[_loc1_.pos] = false;
delete _loc1_.pos;
}
}
}
else if(_loc1_.type == 1)
{
if(_loc1_.pos != undefined)
{
if(_loc1_._y > 200)
{
_loc2_.available[_loc1_.pos] = false;
delete _loc1_.pos;
}
}
}
else if(_loc1_.type == 2)
{
_loc1_._x += _loc1_.dir;
}
else if(_loc1_.type == 3)
{
_loc1_.smoke();
if(!_loc1_.start)
{
_loc1_._y -= 1;
if(_loc1_._y > 170)
{
_loc1_.start = true;
}
}
else
{
_loc1_.update();
}
}
if(_loc1_._y > 580)
{
if(_loc1_.type == 2)
{
_loc2_.snakeCount -= 1;
}
else if(_loc1_.type == 3)
{
_loc2_.bikeCount -= 1;
}
removeMovieClip(_loc1_);
}
}
};